package cn.com.nes.site.module.service.newmall;

import cn.com.nes.common.util.DBUtils;
import cn.com.nes.site.entity.DataReq;
import cn.com.nes.site.entity.PageData;
import cn.com.nes.site.module.dao.newmall.NewmallBookingDaoImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Map;

@Service
public class NewmallBookingService {
    @Resource
    private NewmallBookingDaoImpl impl;

    public PageData saveBookingInfo(DataReq req) throws SQLException {
        Connection conn = null ;
        PageData res = new PageData() ;
        try {
            conn = DBUtils.getJNDIDBConn();
            res =  impl.saveBookingInfo(conn,req);
            if(res.getRetCode()==0) {
                conn.commit();
            }
        }catch (Exception e) {
            e.printStackTrace();
            conn.rollback();
        }finally {
            if(conn!=null)
                conn.close();
        }
        return res ;
    }

    public PageData getBookingList(DataReq req) throws SQLException {
        return impl.getBookingList(req);
    }

    public Map<String, Object> getCompanyById(DataReq req) throws SQLException {
        return impl.getCompanyById(req);
    }
}
